



// function sayHello(){
//   console.log(this.name)
// }


interface IUser {
  name: string,
  age: number,
  sayHello(this: IUser): void
}

const u: IUser = {
  name: 'ssf',
  age: 23,
  sayHello() {
    console.log(this.name)
  }
}

const say = u.sayHello
// say()



class User {
  constructor(
    public name: string
  ) { }
  // 约定this指向
  say(this: User) {
    console.log(this.name);
  }
}